<%@ page import="dao.MajorDao" %>
<%@ page import="entity.Major" %>
<%@ page import="java.util.List" %>
<%@ page import="dao.CollegeDao" %>
<%@ page import="entity.College" %><%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2024/10/30
  Time: 14:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>专业信息管理</title>
</head>
<body>
    <a href="major_add.jsp" >+新增专业</a>

  <table>
      <tr>
          <td>id</td><td>专业名称</td><td>所在学院</td>
      </tr>
      <%
        //调用MajaroDao的getAll()获得所有专业列表，生成<tr>
        CollegeDao  collegeDao  = new CollegeDao();
        List<Major> list = new MajorDao().getAll();
        for(Major obj:list){
            out.println("<tr>");
                out.println("<td>"+ obj.getId() +"</td>");
                out.println("<td>"+ obj.getName() +"</td>");
                 //调用CollegeDao 的 getById() 取得对应的学院对象
                 //将对应的学院名称显示在该列
                  College  college  =
                          collegeDao.getById(obj.getCollege_id());
                out.println("<td>"+ college.getName() +"</td>");

                out.println("<td>"
                                +"<a href=\"major_edit.jsp?id="+obj.getId()+"\" >修改</a>"
                           +"</td>");
                out.println("</tr>");
        }
      %>

  </table>

</body>
</html>
